package cloud.take.off.controller.order;

import cloud.take.off.module.common.CommonCode;
import cloud.take.off.module.common.R;
import cloud.take.off.module.order.dto.BaseOrderDTO;
import cloud.take.off.module.order.vo.BaseOrderVO;
import cloud.take.off.mybatis.base.PageData;
import cloud.take.off.service.order.IBaseOrderService;
import cn.hutool.system.UserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2024/10/9 2:16 PM
 * @Param
 * @return
 * @Version: 1.0
 **/
@RestController
@RequestMapping("/order")
@AllArgsConstructor
@Api(value = "订单管理", tags = "订单系统-订单管理")
public class BaseOrderController {

    public final IBaseOrderService baseOrderService;

    @PostMapping("/submit")
    @ApiOperation(value = "新增或修改", notes = "新增或修改")
    public R submit(@RequestBody BaseOrderVO baseOrderVO){
        boolean result = baseOrderService.submit(baseOrderVO);
        return R.status(result);
    }

    @PostMapping("/detail")
    @ApiOperation(value = "详情", notes = "详情")
    public R<BaseOrderVO> detail(@RequestBody BaseOrderDTO baseOrderDTO){
        BaseOrderVO baseOrderVO = baseOrderService.detail(baseOrderDTO);
        return R.data(baseOrderVO);
    }

    @PostMapping("/remove")
    @ApiOperation(value = "删除", notes = "传入 ids")
    public R remove(@RequestBody BaseOrderDTO dto) {
        boolean result = baseOrderService.deleteLogic(dto.getIds());
        return R.status(result);
    }

}
